<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>兜兜集</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        .center {
            width: 1200px;
            margin: 0 auto;
        }

        body {
            overflow: hidden;
        }
        .infinite-list {
            flex-wrap: wrap; /* 让数据项自适应换行 */
            justify-content: flex-start;
            align-items: center;
            height: 800px;
            width: 1450px;
            overflow-y: scroll;
            display: grid;
            grid-template-columns: repeat(4, 1fr); /* 商品分成4列 */
            gap: 32px; /* 列与列之间空隙为15像素 */
        }

        .infinite-list-item {


            background-color: #c3c8c8;
            height: 430px;
            width: 100%; /* 设置为百分比 */

        }

        ul {
            list-style: none;
            overflow-y: auto;
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* Internet Explorer and Edge */
        }

        /* 针对 Chrome、Safari 和 Opera */
        ul::-webkit-scrollbar {
            display: none;
        }

        .center {
            max-width: 1200px;
            margin: 0 auto;
        }

        .header {
            background-color: #ffffff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        .search-bar {
            margin-top: 15px;
            height: 40px;
            line-height: 20px;
            border-radius: 4px;
            font-size: 14px;
            font-weight: 500;
            color: #333;
        }
        .icon-wrapper {
            position: relative;
            top: 12px;
        }

        #menu_aside{
            display: flex;
            flex-direction: column;
            line-height: 5px;
        }

    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header height="80px" class="header">
            <div class="center">
                <el-row type="flex" justify="space-between" align="middle" :gutter="20">
                    <el-col span="6">
                        <img src="imgs/Logo.png" width="196" height="65"/>
                    </el-col>
                    <el-col span="12">
                        <el-input
                                class="search-bar"
                                placeholder="请输入搜索的关键字"
                                suffix-icon="el-icon-search"
                        ></el-input>
                    </el-col>
                    <el-col span="4">
                        <div style="display:flex; justify-content:center; align-items:center; width:100%;">
                            <el-menu mode="horizontal" active-text-color="orange" style="font-size: 30px">
                                <el-menu-item index="0" style="font-size: 20px">首页</el-menu-item>
                                <el-menu-item index="1" style="font-size: 20px">商城</el-menu-item>
                            </el-menu>
                        </div>
                    </el-col>
                    <el-col span="2">
                        <el-popover
                                placement="bottom-start"
                                title="兜兜集欢迎你!"
                                width="200"
                                trigger="hover"
                        >
                            <div slot="reference" class="icon-wrapper" style="position: absolute;padding: 5px 50px  15px  50px" >
                                <i class="el-icon-user" style="font-size: 2rem" ></i>
                            </div>
                            <el-button type="info">注册</el-button>
                            <el-button style="background-color: orange">登录</el-button>
                        </el-popover>
                    </el-col>
                </el-row>
            </div>
        </el-header>
        <el-container class="aside_main">
            <el-aside width="200px" style="margin-right: 10px; padding: 5px;">
                <div style="position: relative; display: flex; flex-direction: column; align-items: center;">
                    <div style="display: flex; flex-wrap: wrap; position: absolute;padding-right: 5px">


                        <el-menu id="menu_aside" mode="horizontal" @select="categorySelect" default-active="0" active-text-color="orange">
                            <el-menu-item v-for="(category,index) in categoriesArr"  :index="String(index)">{{category.name}}</el-menu-item>
                        </el-menu>


                    </div>
                    <div style="position: absolute; padding-right: 10px; top: 650px">
                        <el-row>
                            <el-button round style="margin-bottom: 10px; border: none;">主页</el-button>
                            <br>
                            <el-button round style="margin-bottom: 10px; border: none;">发布</el-button>
                            <br>
                            <el-button round style="margin-bottom: 10px;">登录</el-button>
                        </el-row>
                    </div>
                </div>
            </el-aside>


            <el-main style="padding: 5px;margin-left:-10px;">
                <div>
                    <template>
                        <div class="infinite-list-demo">
                            <ul class="infinite-list" v-infinite-scroll="load">


                                <el-card v-for="i in card" :key="i" class="infinite-list-item" style="background-color: rgba(223,231,215,0.85);padding: 0;">
                                    <img :src="i.imagesUrl" style="width: 100%;display: inline-block;">
                                    <p>{{i.title}}</p>
                                    <el-row>
                                        <el-col span="4">
                                            <el-avatar style="vertical-align: middle;margin-bottom: 10px;display: inline-block" size="lager" :src="i.iconUrl"></el-avatar>
                                        </el-col>
                                        <el-col span="20" style="margin-bottom: 10px">
                                            <p style="display: inline-block;font-size: 22px;vertical-align: middle;margin-top: 5px">{{i.userName}}</p>
                                        </el-col>
                                    </el-row>
                                </el-card>


                            </ul>
                        </div>
                    </template>
                </div>
            </el-main>


        </el-container>
    </el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<!--引入Axios-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>

<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                card:[],
                tabPosition: 'left',
                count: 0,
                articleArr: [],
                categoriesArr: []
            }
        },
        methods: {

            load() {
                this.count += 4
            },

            //发请求获取某个分类下的数据
            categorySelect(key){
                console.log(key);
                axios.get("/v1/blogs/"+ key +"/index").then((response)=>{
                    if (response.data.code==200){
                        v.card=response.data.data;
                    }
                })
            }
        },

        created: function () {
            axios.get("/v1/blogs/0/index").then( (response)=> {
                if (response.data.code==200){
                    v.card=response.data.data;
                }

            })
            axios.get("/v1/blogs/allCategories").then((response)=>{
                if (response.data.code==200){
                    console.log(response.data.data);
                    v.categoriesArr=response.data.data;
                }
            })
        }
    })
</script>
</html>

